home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ansi / txtcap20.zip / SCN2ASC.PAS < prev    next >
Pascal/Delphi Source File  |  1991-12-04  |  2KB  |  63 lines

  1. Program scn2asc;
  2. { Filter to convert screen captured by TEXTCAP to plain ASCII file           }
  3. { I.e., throw out display attribute bytes, reformat in lines of 80 columns   }
  4. { (or whatever is specified on the command line).                            }
  5. { Free Software by TapirSoft Gisbert W.Selke, Dec 1991                       }
  6.  
  7.   Const progname = 'Scn2Asc';
  8.         version  = '1.0';
  9.         copyright= 'Free Software by TapirSoft Gisbert W.Selke, Dec 1991';
  10.  
  11.         bufsize  = 30000; { must be even! }
  12.  
  13.   Type iobuffer  = Array [0..bufsize-1] Of char;
  14.  
  15.   Var  inf : File;
  16.        outf : text;
  17.        inbuf, outbuf : iobuffer;
  18.        n : longint;
  19.        i, iread : word;
  20.        ires : integer;
  21.        k, len : byte;
  22.  
  23. Begin
  24.   len := 80;
  25.   For i := 1 To ParamCount Do
  26.   Begin
  27.     Val(ParamStr(i),n,ires);
  28.     If (ires <> 0) Or (n <= 0) Or (n > 255) Then
  29.     Begin
  30.       writeln(progname,' ',version,' - ',copyright);
  31.       writeln('Illegal command line argument - must be between 1 and 255');
  32.       Halt(1);
  33.     End;
  34.     len := n;
  35.   End;
  36.   i := FileMode;
  37.   FileMode := 0;
  38.   Assign(inf,'');
  39.   Reset(inf,1);
  40.   FileMode := i;
  41.   Assign(outf,'');
  42.   Rewrite(outf);
  43.   SetTextBuf(outf,outbuf);
  44.   k := 0;
  45.   While Not EoF(inf) Do
  46.   Begin
  47.     BlockRead(inf,inbuf,SizeOf(inbuf),iread);
  48.     For i := 0 To Pred(iread) Div 2 Do
  49.     Begin
  50.       write(outf,inbuf[2*i]);
  51.       Inc(k);
  52.       If k = len Then
  53.       Begin
  54.         writeln(outf);
  55.         k := 0;
  56.       End;
  57.     End;
  58.   End;
  59.   Close(inf);
  60.   Flush(outf);
  61.   Close(outf);
  62. End.
  63.